<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>

<?php 
	$USER = getAccountUserObject();
	$paymentHistory = $this->payment_history->getPaymentHistoryOfAgent($USER->getId());
?>
<style>
	
</style>
 
<div id="content-left">
	<div id="personal-tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
		<div id="tabs-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
			<!-- content -->	
			<?php $i =0; foreach($paymentHistory as $item): ?>
			<div id="wrap_<?php echo $item->id;?>">
			
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('payment_history_datetime');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<?php echo sysDateFormat($item->datetime, DATE_FORMAT);?> 
						</div>
					</div>
					<div class="clear"></div>
				</div>
				
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('services_page_net_amount');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<span id="current_price" style="float:left;"> <?php echo euroCurrencyFormat( format($item->net_amount) ) .' &euro;';?></span> 
						</div>
					</div>
					<div class="clear"></div>
				</div>
			
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('services_page_payment_status');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<span style="float:left;"> 
								<?php
									$status = $this->payment_history->getPaymentStatus($item->id);	
									if($status){
										echo language_translate('services_page_payment_status_'.$status);
									}
								?>
							</span> 
						</div>
					</div>
					<div class="clear"></div>
				</div>
				
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('services_page_payment_details');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<span style="float:left;"> 
								<?php
									$status = $this->payment_history->getPaymentStatus($item->id);	
									if($status == 'yes'){
										$cancelable = false;
										echo anchor( site_url_lang("agent/account/export_pdf/{$item->id}"), language_translate('services_page_payment_get_invoice') ,'target="_blank"' );
									}else{
										$cancelable = true;
										echo anchor( site_url_lang("agent/account/order/{$item->id}"),language_translate('services_page_payment_see_order'));
									}
								?>
							</span> 
						</div>
					</div>
					<div class="clear"></div>
				</div>
				
				<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span><?php echo language_translate('contract_order_orderid');?></span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<span style="float:left;"> 
								<?php
									echo $item->id;
								?>
							</span> 
						</div>
					</div>
					<div class="clear"></div>
				</div>
				
				<?php if($cancelable):?>
					<div class="dashboard-info-wrapper">
					<div class="dashboard-info-left"><span>&nbsp;</span></div>
					<div class="dashboard-info-right">
						<div class="select-box">
							<input type="button" class="save-button" value="<?php echo language_translate('order_cancel');?>" onclick="callFuncCancelOrder(<?php echo $item->id;?>,'<?php echo makeSalt($item->id);?>')" />
						</div>
					</div>
					<div class="clear"></div>
				</div>
				<?php endif;?>
				
				<div class="clear"></div>
				<hr class="background-separate"/>
				
				<?php $i++;?>
			</div>	
			<?php endforeach;?>
			
			<?php if($i==0){
				echo language_translate('payment_history_message_1');		
			}?>
			<!-- end content -->
		</div>
	</div>
</div>
 

<?php $this->load->view('agent/right_nav'); ?>



<script type="text/javascript">
	$(document).ready(function() { 
		
	});	

	function callFuncCancelOrder(id,str){
		$.post(BASE_URI+'home/services_reg_async/cancelOrder',{id:id,s:str},function(res){
			if(res=='ok'){
				$('#wrap_'+id).fadeOut();
			}
		})
	}
</script>